package com.example.security_demo.controller;

import com.example.security_demo.bo.SmsLoginBo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * 通过手机号码获取验证码
 *
 * @author zzh
 * @date 2022/4/20
 * @since 1.0
 */
@RestController
public class SmsCodeSendController {



    @GetMapping("/sms/code")
    public String sendCode(String phoneNumber) {
        System.out.println(phoneNumber);
        return "smsCode";
    }

    @PostMapping("/sms/loginOne")
    public String smsLogin(@RequestBody SmsLoginBo smsAuthenticationToken) {

        System.out.println(smsAuthenticationToken.getMobile());
        System.out.println(smsAuthenticationToken.getSmsCode());
        // 如果认证成功就返回对应的token 后续根据token对用户进行验证
        return UUID.randomUUID().toString().replace("-", "");
    }
}
